package com.example.a17376046_xsh_finaltest.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.a17376046_xsh_finaltest.R;
import com.example.a17376046_xsh_finaltest.entity.Dynamic;
import java.util.List;

public class DynamicAdapter extends BaseAdapter {
    List<Dynamic> mList;
    Context context;
    LayoutInflater mLayoutInflater;
    public DynamicAdapter(List<Dynamic> mList, Context context) {
        this.mList = mList;
        this.context = context;
    }
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        mLayoutInflater = LayoutInflater.from(context);
        View view = mLayoutInflater.inflate(R.layout.item_dynamic, null);
        ImageView imgv_dyhead=view.findViewById(R.id.imgv_dyhead);
        TextView tv_dyname=view.findViewById(R.id.tv_dyname);
        TextView tv_dytime=view.findViewById(R.id.tv_dytime);
        TextView tv_dytype=view.findViewById(R.id.tv_dytype);
        ImageView image_dy=view.findViewById(R.id.image_dy);
        imgv_dyhead.setImageResource(mList.get(position).getImgv_dyhead());
        tv_dyname.setText(mList.get(position).getTv_dyname());
        tv_dytime.setText(mList.get(position).getTv_dytime());
        tv_dytype.setText(mList.get(position).getTv_dytype());
        image_dy.setImageResource(mList.get(position).getImage_dy());
        return view;
    }
}
